<?php
class Admin_Model_Media extends Zend_Db_Table_Abstract
{
	public function getallimg()
	{
		$db = Zend_Registry::get('connectDB');
		$data = $db->fetchAll($db->select()->from('urlimage')->joinInner('product','product.id_product=urlimage.id_product'));
		return $data;
	}
	public function getallvideo()
	{
		$db = Zend_Registry::get('connectDB');
		$data = $db->fetchAll($db->select()->from('urlvideo')->joinInner('product','product.id_product=urlvideo.id_product'));
		return $data;
	}
	public function searchimg($content)
	{
		$db = Zend_Registry::get('connectDB');
		$where = $db->quoteInto('filename LIKE ? OR pixel LIKE ? OR size LIKE ?','%'.$content.'%');
		$data = $db->fetchAll($db->select()->from('urlimage')->joinInner('product','product.id_product=urlimage.id_product')->where($where));
		return $data;
	}
	public function searchvideo($content)
	{
		$db = Zend_Registry::get('connectDB');
		$where = $db->quoteInto('filename LIKE ? OR size LIKE ?','%'.$content.'%');
		$data = $db->fetchAll($db->select()->from('urlvideo')->joinInner('product','product.id_product=urlvideo.id_product')->where($where));
		return $data;
	}
	public function delimg($id)
	{
		$db = Zend_Registry::get('connectDB');
		$where = $db->quoteInto('id_urlimg =?',$id);
		$delete = $db->delete('urlimage',$where);
		return $delete;
	}
	public function delvideo($id)
	{
		$db = Zend_Registry::get('connectDB');
		$where = $db->quoteInto('id_urlvideo =?',$id);
		$delete = $db->delete('urlvideo',$where);
		return $delete;
	}
}